#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char a[15][15];
bool v[1600005];
//上右下左
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int fx,fy,cx,cy;
int ans=0;
void move(int &x,int &y,int &d){
	int nx=x+dx[d],ny=y+dy[d];
	if(a[nx][ny]=='*'){
		d=(d+1)%4;
		return ;
	}else{
		x=nx;
		y=ny;
	}
	
}

int main(){
	memset(a,'*',sizeof(a));
	for(int i=1;i<=10;i++){
		for(int j=1;j<=10;j++){
			cin>>a[i][j];
			if(a[i][j]=='F'){
				fx=i;
				fy=j;
			}else if(a[i][j]=='C'){
				cx=i;
				cy=j;
			}
		}
	}
	int df=0,dc=0;
	while(!(fx==cx&&fy==cy)){
		int state=fx+fy*10+df*100+cx*1000+cy*10000+dc*100000;
		if(v[state]){
			cout<<0;
			return 0;
		}
		v[state]=1;
		move(fx,fy,df);
		move(cx,cy,dc);
		ans++;
	}
	cout<<ans;

	return 0;
}
